{% extends "staff/base.html" %}
{% import 'staff/_formhelpers.html' as forms with context %}

{% block title %} {{ assignment.display_name }} - {{ current_course.display_name_with_semester }}{% endblock %}

{% block main %}
  <section class="content-header">
      <h1>
        {{ assignment.display_name }}
        <small>{{ current_course.offering }}</small>
      </h1>
      <ol class="breadcrumb">
        <li><a href="{{ url_for(".course", cid=current_course.id) }}">
            <i class="fa fa-university"></i> {{ current_course.offering }}
        </a></li>
        <li><a href="{{ url_for('.course_assignments', cid=current_course.id) }}">
          <i class="fa fa-list"></i> Assignments</a>
        </li>
        <li class="active hidden-xs"><a href="{{ url_for('.assignment', cid=current_course.id, aid=assignment.id) }}"><i class="fa fa-book"></i> {{ assignment.display_name }} </a></li>
      </ol>
  </section>

  <!-- Don't close the content section -->
  <section class="content">
      {% include 'alerts.html' %}
          <div class="row">
                  <div class="col-md-12">
                    <div class="box">
                      <div class="box-header with-border">
                        <h3 class="box-title">Info</h3>
                        <div class="box-tools pull-right">
                          <button type="button" class="btn btn-box-tool" data-widget="collapse"><i class="fa fa-minus"></i>
                          </button>
                        </div>
                      </div>
                      <!-- /.box-header -->
                      <div class="box-body">

                        <div class="row">
                          <div class="col-sm-6 col-xs-6">
                            <div class="description-block border-right">
                              <h5 class="description-header"> {{ utils.local_time(assignment.due_date, current_course)  }} </h5>
                              <span class="description-text">Due Date</span>
                            </div>
                          </div>
                          <div class="col-sm-6 col-xs-6">
                            <div class="description-block border-right">
                                <h5 class="description-header"> {{ utils.local_time(assignment.lock_date, current_course)  }} </h5>
                                <span class="description-text">Lock Date</span>
                            </div>
                          </div>
                        </div>
                        <!-- /.row -->


                      </div>
                      <!-- ./box-body -->
                      <!-- /.box-footer -->
                    </div>
                    <!-- /.box -->
                  </div>
                  <!-- /.col -->
                </div>

        <!-- Default box -->
        <div class="row">
          <div class="col-md-4">
            <div class="box box-solid">
              <div class="box-header with-border">
                <h3 class="box-title">Actions</h3>

                <div class="box-tools">
                  <button type="button" class="btn btn-box-tool" data-widget="collapse"><i class="fa fa-minus"></i>
                  </button>
                </div>
              </div>
              <div class="box-body no-padding">
                <ul class="nav nav-pills nav-stacked">
                  <li class="active"><a href="#"><i class="fa fa-book"></i> Overview
                    {% if assignment.active %}
                      <span class="label label-success pull-right">Active</span></a>
                    {% else %}
                      <span class="label label-warning pull-right">Inactive</span></a>
                    {% endif %}
                  </li>
                  <li> <a href="{{ url_for('.assignment_stats', cid=current_course.id, aid=assignment.id) }}" type="button">
                        <i class="fa fa-bar-chart-o"></i> Detailed Stats
                  </a></li>
                  <li> <a href="{{ url_for('.view_scores', cid=current_course.id, aid=assignment.id) }}" type="button">
                        <i class="fa fa-eye"></i> View Scores
                  </a></li>
                  <li> <a href="{{ url_for('.create_extension', cid=current_course.id, aid=assignment.id) }}" type="button">
                        <i class="fa fa-calendar"></i> Grant Extension
                  </a></li>
                  <li> <a href="{{ url_for('.effort_grading', cid=current_course.id, aid=assignment.id) }}" type="button">
                        <i class="fa fa-thumbs-up"></i> Effort Grading
                  </a></li>
                  <li> <a href="{{ autograder_url }}" target="_blank" type="button">
                        <i class="fa fa-gear"></i> Configure Autograder
                  </a></li>
                  <li>
                    {% call forms.render_form_bare(CSRFForm(), action_url=url_for('.autograde', cid=current_course.id, aid=assignment.id), class_='form') %}
                        <button type="submit" class="ag-submit-btn" data-confirm="Send all submissions to the autograder?"> <i class="fa fa-send"></i> Queue on Autograder
                        </button>
                    {% endcall %}
                 </li>
                  <li> <a href="{{ url_for('.templates', cid=current_course.id, aid=assignment.id) }}" type="button">
                     <i class="fa fa fa-file-text-o"></i> Edit Assignment Template
                  </a></li>
                  <li> <a href="{{ url_for('.assign_grading', cid=current_course.id, aid=assignment.id) }}" type="button">
                        <i class="fa fa-user-plus"></i> Assign Grading
                  </a></li>
                  <li> <a href="{{ url_for('.assignment_queues', cid=current_course.id, aid=assignment.id) }}" type="button">
                        <i class="fa fa-inbox"></i> Grading Queues
                  </a></li>
                  <li> <a href="{{ url_for('.checkpoint_grading', cid=current_course.id, aid=assignment.id) }}" type="button">
                        <i class="fa fa-check"></i> Checkpoint Grading
                  </a></li>
                  <li> <a href="{{ url_for('.upload', cid=current_course.id, aid=assignment.id) }}" type="button">
                    <i class="fa fa-upload"></i> Upload Scores
                  </a></li>
                  <li> <a href="{{ url_for('.export_submissions', cid=current_course.id, aid=assignment.id) }}" type="button">
                        <i class="fa fa-file-archive-o"></i> Download Submissions
                  </a></li>
                  <li> <a href="{{ url_for('.start_moss_job', cid=current_course.id, aid=assignment.id) }}" type="button">
                        <i class="fa fa-gavel"></i> Run MOSS
                  </a></li>
                  <li> <a href="{{ url_for('.assignment_moss_results', cid=current_course.id, aid=assignment.id) }}" type="button">
                        <i class="fa fa-list"></i> Moss Results
                  </a></li>
                  <li> <a href="{{ url_for('.start_github_search', cid=current_course.id, aid=assignment.id) }}" type="button">
                        <i class="fa fa-github"></i> Search Github
                  </a></li>
                </ul>
              </div>
              <!-- /.box-body -->
            </div>
            <!-- /. box -->
          </div>

            <div class="col-md-8">
              <div class="box">
                <div class="box-header with-border">
                  <h3 class="box-title">Edit {{ assignment.display_name }} Assignment</h3>
                  <div class="box-tools pull-right">
                    <button type="button" class="btn btn-box-tool" data-widget="collapse" data-toggle="tooltip" title="Collapse">
                      <i class="fa fa-minus"></i>
                    </button>
                  </div>
                </div>
                <div class="box-body">
                    <!-- form goes here -->
                    {% call forms.render_form(form, action_url="", action_text='Update Assignment', class_='form') %}
                        {{ forms.render_field(form.display_name, label_visible=true, placeholder='Hog', type='text') }}
                        {{ forms.render_field(form.name, label_visible=true, placeholder='cal/cs61a/fa16/proj01', type='text') }}
                        {{ forms.render_field(form.max_group_size, label_visible=true, type='number', min='1') }}
                        {{ forms.render_field(form.due_date, label_visible=true, placeholder=utils.new_due_date(current_course), type='text', class='form-control datetime-picker') }}
                        {{ forms.render_field(form.lock_date, label_visible=true, placeholder=utils.new_lock_date(current_course), type='text', class='form-control datetime-picker') }}
                        {{ forms.render_field(form.url, label_visible=true, placeholder='http://cs61a.org/proj/hog/ (Optional)', type='text') }}
                        {{ forms.render_checkbox_field(form.visible, label_visible=true) }}
                        {{ forms.render_field(form.autograding_key, label_visible=true, placeholder='5abc... (Optional)', type='text') }}
                        {{ forms.render_checkbox_field(form.continuous_autograding, label_visible=true) }}
                        {{ forms.render_checkbox_field(form.revisions_allowed, label_visible=true) }}
                        {{ forms.render_checkbox_field(form.uploads_enabled, label_visible=true) }}
                        {{ forms.render_field(form.upload_info, label_visible=true, placeholder='Upload the following files: test.py', type='text') }}
                    {% endcall %}
                </div>
                <!-- /.box-body -->
                <!-- /.box-footer-->
              </div>
              <!-- /.box -->
            </div>
        </div>

  <!-- </body> do not close body in template-->
{% endblock %}
